package com.yunfei.excel_insert.web.dao;

import com.yunfei.excel_insert.web.dataobject.ZhangyunfeiExcelInsert;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
@Mapper
public interface ZhangyunfeiExcelInsertMapper {
    @Delete({
        "delete from zhangyunfei_excel_insert",
        "where tel_number = #{telNumber,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String telNumber);

    @Insert({
        "insert into zhangyunfei_excel_insert (tel_number, staff_name, ",
        "port, password)",
        "values (#{telNumber,jdbcType=VARCHAR}, #{staffName,jdbcType=VARCHAR}, ",
        "#{port,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR})"
    })
    int insert(ZhangyunfeiExcelInsert record);

    @Select({
        "select",
        "tel_number, staff_name, port, password",
        "from zhangyunfei_excel_insert",
        "where tel_number = #{telNumber,jdbcType=VARCHAR}"
    })
    @Results( id = "excelRecordMap" , value = {
        @Result(column="tel_number", property="telNumber", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="staff_name", property="staffName", jdbcType=JdbcType.VARCHAR),
        @Result(column="port", property="port", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR)
    })
    ZhangyunfeiExcelInsert selectByPrimaryKey(String telNumber);

    @Select({
            "select",
            "tel_number, staff_name, port, password",
            "from zhangyunfei_excel_insert",
            "where port = #{port,jdbcType=VARCHAR}"
    })
    @ResultMap("excelRecordMap")
    ZhangyunfeiExcelInsert selectByPort(String port);



    @Select({
        "select",
        "tel_number, staff_name, port, password",
        "from zhangyunfei_excel_insert"
    })
    @Results({
        @Result(column="tel_number", property="telNumber", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="staff_name", property="staffName", jdbcType=JdbcType.VARCHAR),
        @Result(column="port", property="port", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR)
    })
    List<ZhangyunfeiExcelInsert> selectAll();

    @Update({
        "update zhangyunfei_excel_insert",
        "set staff_name = #{staffName,jdbcType=VARCHAR},",
          "port = #{port,jdbcType=VARCHAR},",
          "password = #{password,jdbcType=VARCHAR}",
        "where tel_number = #{telNumber,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(ZhangyunfeiExcelInsert record);

}